package com.magicalcoder.youyamvc.app.module.dao.impl;

import com.magicalcoder.youyamvc.app.model.defined.IntegerDate;
import com.magicalcoder.youyamvc.app.model.defined.IntegerObject;
import com.magicalcoder.youyamvc.app.module.dao.ModuleDao;
import com.magicalcoder.youyamvc.app.model.Module;
import com.magicalcoder.youyamvc.app.model.defined.ModuleWithModuleCategory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* 代码为自动生成 Created by www.magicalcoder.com
* 如果你改变了此类 read 请将此行删除
* 欢迎加入官方QQ群:323237052
*/

@Component("moduleDao")
public class ModuleDaoImpl   implements ModuleDao {

    @Resource(name="sqlSessionTemplate")
    private  SqlSessionTemplate  sqlSessionTemplate;
    @Override
    public Module getModule(Map<String, Object> query) {
        return sqlSessionTemplate.selectOne("ModuleMapper.getModule",query);
    }
    @Override
    public List<Module> getModuleList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("ModuleMapper.getModuleList", query);
    }
    @Override
    public Integer getModuleListCount(Map<String, Object> query) {
        return sqlSessionTemplate.selectOne("ModuleMapper.getModuleListCount", query);
    }

    @Override
    public void batchInsertModule(List<Module> list) {
        sqlSessionTemplate.insert("ModuleMapper.batchInsertModule",list);
    }

    @Override
    public void batchReplaceModule(List<Module> list) {
        sqlSessionTemplate.insert("ModuleMapper.batchReplaceModule",list);
    }

    @Override
    public void batchUpdateModule(List<Module> list) {
        sqlSessionTemplate.update("ModuleMapper.batchUpdateModule",list);
    }

    @Override
    public     Long  insertModule(Module entity) {
        sqlSessionTemplate.insert("ModuleMapper.insertModule",entity);
  return entity.getId();    }

    @Override
    public     Long  replaceModule(Module entity) {
        sqlSessionTemplate.insert("ModuleMapper.replaceModule",entity);
  return entity.getId();    }

    @Override
    public void updateModule(Module entity) {
        sqlSessionTemplate.update("ModuleMapper.updateModule", entity);
    }
    @Override
    public void updateModuleWithoutNull(Module entity) {
        sqlSessionTemplate.update("ModuleMapper.updateModuleWithoutNull", entity);
    }
    @Override
    public void updateModuleByWhereSql(Map<String,Object> entity) {
        sqlSessionTemplate.update("ModuleMapper.updateModuleByWhereSql", entity);
    }
    @Override
    public List<ModuleWithModuleCategory> getModuleWithModuleCategoryByModuleCategoryIdList(Map<String, Object> query){
        return sqlSessionTemplate.selectList("ModuleMapper.getModuleWithModuleCategoryByModuleCategoryIdList", query);
    }
    @Override
    public void truncateModule() {
        sqlSessionTemplate.delete("ModuleMapper.truncateModule");
    }
    @Override
    public void deleteModule(Map<String, Object> query) {
        sqlSessionTemplate.delete("ModuleMapper.deleteModule",query);
    }
    @Override
    public void deleteModuleList(Map<String, Object> query) {
        sqlSessionTemplate.delete("ModuleMapper.deleteModuleList",query);
    }
    @Override
    public void deleteModuleByWhereSql(Map<String, Object> query) {
        sqlSessionTemplate.delete("ModuleMapper.deleteModuleByWhereSql",query);
    }
    @Override
    public void batchDeleteModule(List<Long> list) {
        sqlSessionTemplate.delete("ModuleMapper.batchDeleteModule",list);
    }
    @Override
    public void batchDeleteModuleList(List<Module> list) {
        sqlSessionTemplate.delete("ModuleMapper.batchDeleteModuleList",list);
    }

    @Override
    public List<IntegerDate> statisticsDateCountList(Map<String, Object> query) {
    return sqlSessionTemplate.selectList("ModuleMapper.statisticsDateCountList", query);
    }

    @Override
    public List<IntegerDate> statisticsDateIntervalList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("ModuleMapper.statisticsDateIntervalList", query);
    }

    @Override
    public List<IntegerObject> statisticsGroupList(Map<String, Object> query) {
        return sqlSessionTemplate.selectList("ModuleMapper.statisticsGroupList", query);
    }
}
